package model.MatriceCreuseOBSOLETE;

import model.PointControl;

public class Line {
	private double y;
	private Line previous;
	private Line next;
	private PointControl pointCourant;
	private Line thisLine = this;

	public Line getThisLine() {
		return thisLine;
	}

	private void setThisLine(Line thisLine) {
		this.thisLine = thisLine;
	}

	public Line(double y, PointControl pointCourant) {
		this.y = y;
		this.pointCourant = pointCourant;
	}

	public PointControl getPointCourant() {
		return pointCourant;
	}

	public void setCurrentPoint(PointControl pointCourant) {
		this.pointCourant = pointCourant;
	}

	public Line getPrevious() {
		return previous;
	}

	private void setPrevious(Line previous) {
		this.previous = previous;
	}

	public Line getNext() {
		return next;
	}

	private void setNext(Line next) {
		this.next = next;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	/*
	 * Insère une ligne entre 2
	 */
	public void insertLine(Line ligne) {
		Line suivant = this.next;
		if (suivant != null)
			suivant.setPrevious(ligne);
		ligne.setNext(suivant);

		this.setNext(ligne);
		ligne.setPrevious(this);
	}

	public void removeMe() {
		Line suivant = this.next;
		Line precedent = this.previous;
		if (suivant == null && precedent == null)
			this.setThisLine(null);
		if (suivant != null) {
			suivant.setPrevious(precedent);
			this.setThisLine(precedent);
		}

		if (precedent != null) {
			precedent.setNext(suivant);
			this.setThisLine(suivant);
		}

	}

	public void insertLineBefore(Line nouvelleLigne) {
		// TODO Auto-generated method stub
		
	}
}